package com.diet.web.controller.diet;

import com.diet.common.core.controller.BaseController;
import com.diet.common.core.domain.AjaxResult;
import com.diet.common.core.page.TableDataInfo;
import com.diet.system.domain.Banner;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 轮播图Controller
 */
@RestController
@RequestMapping("/banner")
public class BannerController extends BaseController
{
    /**
     * 获取轮播图列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Banner banner)
    {
        startPage();
        // 模拟轮播图数据
        List<Banner> list = new ArrayList<>();
        Banner banner1 = new Banner();
        banner1.setId(1L);
        banner1.setTitle("蛋白质的重要性");
        banner1.setSubtitle("均衡饮食的基础");
        banner1.setImage("图片URL");
        banner1.setLinkType("url");
        banner1.setLinkUrl("跳转地址");
        banner1.setType("nutrition");
        banner1.setStatus("1");
        banner1.setSort(1);
        banner1.setClickCount(128L);
        list.add(banner1);
        
        return getDataTable(list);
    }

    /**
     * 获取轮播图详情
     */
    @GetMapping("/{bannerId}")
    public AjaxResult getInfo(@PathVariable("bannerId") Long bannerId)
    {
        Map<String, Object> data = new HashMap<>();
        data.put("id", bannerId);
        data.put("title", "蛋白质的重要性");
        data.put("subtitle", "均衡饮食的基础");
        data.put("content", "详细内容描述...");
        data.put("image", "图片URL");
        data.put("author", "作者名称");
        data.put("readCount", 1024);
        data.put("likeCount", 256);
        data.put("createTime", "2024-01-15 10:30:00");
        
        return AjaxResult.success(data);
    }

    /**
     * 轮播图点击统计
     */
    @PostMapping("/click")
    public AjaxResult clickStatistics(@RequestBody Map<String, Object> params)
    {
        return AjaxResult.success();
    }
}